package com.aaa.controller;

import com.aaa.dao.ActivityDao;
import com.aaa.dao.FcartMapper;
import com.aaa.entity.Forder;
import com.aaa.service.impl.ForderServiceImpl;
import com.wsc.entity.Activity;
import com.wsc.entity.Inventory;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.text.ParseException;
import java.util.List;

@RestController
@RequestMapping("forder")
public class ForderController {
    @Resource
    ForderServiceImpl service;
    @Resource
    ActivityDao activityDao;
    @Resource
    FcartMapper fcartMapper;
    @RequestMapping("selectall")
    public List<Forder> selectall(Integer fuser, Integer pageNum, Integer pageSize){
        return service.selectall(fuser,pageNum,pageSize);
    }
    @RequestMapping("update")
    public Integer update(Integer fuser,Integer id) {
        return service.update(fuser,id);
    }
    @RequestMapping("update1")
    public Integer update1(Integer fuser,Integer id) {
        return service.update1(fuser,id);
    }
    @RequestMapping("add")
    public Integer add(Forder forder){
        return service.add(forder);
    }
    @RequestMapping("upadd")
    public boolean upadd(Forder forder){
        return service.upadd(forder);
    }
    @RequestMapping("fadd")
    public Integer fadd(Integer fuser, Integer parcelid, String time, double price, String date,
                        Integer fsite, Integer state, String datetime, String outtradeno,Integer book,Integer number)throws ParseException {
        Inventory inventory=new Inventory();
        inventory.setSurplus(number);
        inventory.setBook(book);
        fcartMapper.update1(inventory);
        return service.fadd(fuser,parcelid,time,price,date,fsite,state,datetime,outtradeno);
    }
    @RequestMapping("fadd1")
    public Integer fadd1(Integer fuser, Integer parcelid, String time, double price, String date,
                        Integer fsite, Integer state, String datetime, String outtradeno,Integer aid,Integer number)throws ParseException
    {
        Activity aa=new Activity();
        aa.setAid(aid);
        aa.setNums(number);
        activityDao.update1(aa);
        return service.fadd(fuser,parcelid,time,price,date,fsite,state,datetime,outtradeno);
    }
    @RequestMapping("max")
    public List<Forder> max(){
        return service.max();
    }
}